//
//  CYUploadProgress.m
//  CreditAddressBook
//
//  Created by Lee on 15/7/29.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYUploadProgress.h"
#import "CYProgress.h"

@interface CYUploadProgress ()

@property (weak, nonatomic) IBOutlet UIView *uploadVIew;
@property (weak, nonatomic) IBOutlet UILabel *uploadProgressLabel;
@property (weak, nonatomic) IBOutlet UIView *messageView;
@property (weak, nonatomic) IBOutlet UILabel *messageLabel;

@end

@implementation CYUploadProgress

- (void)setProgress:(CYProgress *)progress {
    _progress = progress;
    
    self.uploadVIew.hidden = !progress.hiddenMessageView;
    CGFloat upload = progress.uploadProgress * 100;
    self.uploadProgressLabel.text = [NSString stringWithFormat:@"%.0f%%", upload];
    self.messageView.hidden = progress.hiddenMessageView;
    self.messageLabel.attributedText = progress.message;
}

+ (instancetype)uploadProgress:(CYProgress *)progress {
    CYUploadProgress *view = [[[NSBundle mainBundle] loadNibNamed:@"CYUploadProgress" owner:nil options:nil] lastObject];
    if (view) {
        view.progress = progress;
    }
    return view;
}


@end
